package gui;

/***
 * @author Ragnvald Fuglestein
 */

import guilib.PlaylistTableModel;

import javax.swing.JTable;
import javax.swing.ListSelectionModel;


public class PlaylistTable extends JTable {
	private static final long serialVersionUID = -1895483563317196435L;

	/***
	 * Will be rewritten to support more than one playlist when a tabbed interface is ready
	 * 
	 * @param name of playlist
	 * @return existing or new playlist table
	 */
	public static JTable get(String name) {
		return new PlaylistTable(name);
	}
	
	public PlaylistTable(String name) {
		final PlaylistTableModel model = new PlaylistTableModel(name);
		setModel(model);
		setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		
		/*addMouseListener(new MouseAdapter() {
	        @Override
	        public void mouseReleased(MouseEvent e) {
	            if (e.isPopupTrigger() && e.getComponent() instanceof JTable ) {
		            int point = rowAtPoint(e.getPoint());
		            if (point >= 0 && point < getRowCount()) {
		                
		            	int selcount = getSelectedRowCount();
		            	if (isRowSelected(point) && selcount > 1) {
		            		//int[] sel = getSelectedRows();
	            			//model.remove(sel);
		            	} else {
		            		model.remove(point);
		            	}
		            } else {
		                clearSelection();
		            }
	            }
	        }
		});*/
		setAutoCreateRowSorter(true);
		setDragEnabled(true);
		/*
    DropMode.USE_SELECTION
    DropMode.ON
    DropMode.INSERT
    DropMode.INSERT_ROWS
    DropMode.INSERT_COLS
    DropMode.ON_OR_INSERT
    DropMode.ON_OR_INSERT_ROWS
    DropMode.ON_OR_INSERT_COLS

		setDropMode();		
		*/
	}
}